public class NameException extends RuntimeException{
    public NameException() {
    }
    public NameException(String message) {
        super(message);
    }
}

class F{
    public String name = "zhangsan";
    public void loginInfo(String userName) throws NameException{
        if (!this.name.equals(userName)) {
            throw new NameException("用户名错误！");
        }
        System.out.println("登陆成功");
    }
    public static void main(String[] args) {
        F f = new F();
        try {
            f.loginInfo("lisi");
        } catch (NameException e) {
            e.printStackTrace();
        }
    }
}
